Skip to main content

Models Directory Documentation

This documentation provides an overview of the various models and APIs integrated in the codebase. The documentation is organized into separate pages for each category to make navigation easier.

Table of Contents

Getting Started

For most models in this library, you'll need to set up appropriate API keys as environment variables. You can use a .env file with the python-decouple library, which is already integrated throughout the codebase.

Example .env file:

CLAUDE_API_KEY=your_claude_api_key
OPENAI_API_KEY=your_openai_api_key
GOOGLE_CLOUD_API_KEY=your_google_api_key
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key

Installation

The models directory requires several dependencies. You can install them using:

pip install -r requirements.txt

Key dependencies include:

  • requests
  • python-decouple
  • boto3
  • google-generativeai
  • anthropic
  • openai
  • pillow
  • shapely
  • numpy
  • opencv-python

Common Usage Pattern

Most modules follow a similar pattern:

  1. Import the required class
  2. Initialize with API credentials (typically from environment variables)
  3. Call specific methods for desired functionality

Example:

from models.ai.anthropic.claude import ClaudeAI

# Initialize with API key from environment variable
claude = ClaudeAI()

# Generate a response
response = claude.generate_response(
prompt="Tell me a story about a magic backpack",
max_tokens=2000
)
print(response["text"])

Error Handling

Most modules implement error handling with appropriate exceptions. It's recommended to wrap API calls in try-except blocks to handle potential API errors, rate limiting, and network issues.

Example:

try:
response = api_client.get_data("some_id")
process_response(response)
except Exception as e:
logger.error(f"API request failed: {str(e)}")
# Handle error appropriately

Next Steps

Click on any of the category links in the Table of Contents to learn more about specific models and their usage.